import urllib.request, urllib.parse

# 请求地址
url = 'https://www.baidu.com/s?wd='

# UA 信息
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'
}

# 将周杰伦三个字变成 unicode 编码
# 利用 urllib.parse
name = urllib.parse.quote('ip地址')
print(name)

# 请求对象定制
request = urllib.request.Request(url=url+name, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode('utf8')

# print(content)
